package com.framework.controller;

import com.framework.entity.flow.FlowAccount;
import com.framework.entity.flow.FlowTask;
import com.framework.entity.sys.SysCard;
import com.framework.exception.util.RespResult;
import com.framework.service.*;
import com.framework.view.FlowAccountView;
import com.framework.view.SeparatMonthView;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Map;

/**
 * 功能描述: 流水控制器
 *
 * @author ck
 * @date 2018/9/26 20:32
 */
@RestController
@Api(value="流水查询模块",tags={"流水查询模块"})
@RequestMapping(value = "flow")
public class FlowController {

	@Autowired
	private FlowAccountService flowAccountService;
	@Autowired
	private FlowActivService flowActivService;
	@Autowired
	private FlowTaskService flowTaskService;
	@Autowired
	private FlowCardService flowCardService;
	@Autowired
	private SysCardService sysCardService;


	/**
	 * 获取近期6个月收益总明细
	 * @param token 当前人登录token
	 * @return
	 */
	@GetMapping("user/queryMonthProfitSumList")
	@ApiOperation("获取近期6个月收益总明细")
	public RespResult queryMonthProfitSumList(String token) {
		Map<String,Object> map = flowAccountService.queryMonthProfitSumList(token);
		return RespResult.ok(map);
	}

	/**
	 *	获取账户支出明细
	 * @param token 当前人登录token
	 * @param flowAccount 对象
	 * @param pageNo 页码
	 * @return
	 */
	@GetMapping("user/queryFlowAccountList")
	@ApiOperation("获取账户支出明细")
	@ApiImplicitParams({
			@ApiImplicitParam(name="pageNo",value="页码",dataType="int", paramType = "query" ,required = true)})
	public RespResult queryFlowAccountList(String token,FlowAccount flowAccount,Integer pageNo) {
		List<FlowAccount> list = flowAccountService.queryFlowAccountList(token, flowAccount, pageNo);
		return RespResult.ok().put("flowList",list);
	}


	/**
	 * 提现明细
	 * @param token
	 * @param flowTask
	 * @param pageNo
	 * @return
	 */
	@GetMapping("user/queryFlowTaskList")
	@ApiOperation("提现流水")
	@ApiImplicitParams({
			@ApiImplicitParam(name="pageNo",value="页码",dataType="int", paramType = "query" ,required = true)
	})
	public RespResult queryFlowTaskList(String token, FlowTask flowTask, Integer pageNo) {
		List<FlowTask> list = flowTaskService.queryFlowTaskList(token,flowTask,pageNo);
		return RespResult.ok().put("list",list);
	}

	/**
	 * 激活返现明细
	 * @param token
	 * @return
	 */
	@GetMapping("user/queryActivInfoList")
	@ApiOperation("激活返现")
	public RespResult queryActivInfoList(String token) {
		List<SeparatMonthView> list = flowActivService.queryActivInfoList(token);
		return RespResult.ok().put("list",list);
	}

	/**
	 * 推荐办卡明细
	 * @param token
	 * @return
	 */
	@GetMapping("user/flowCardInfoList")
	@ApiOperation("推荐办卡明细")
	public RespResult flowCardInfoList(String token) {
		List<SeparatMonthView> list = flowCardService.flowCardInfoList(token);
		return RespResult.ok().put("list",list);
	}

	/**
	 * 推荐办卡-商户明细
	 * @param token 登录人token
	 * @param cardState 审核状态
	 * @param parms 手机号码或者名称
	 * @param pageNo 分页
	 * @return
	 */
	@GetMapping("user/queryCardList")
	@ApiOperation("推荐办卡-商户明细")
	@ApiImplicitParams({
			@ApiImplicitParam(name="cardState",value="状态  AUDIT：审核中 FAIL：失败 SUCCESS:成功",dataType="String", paramType = "query" ,required = true),
			@ApiImplicitParam(name="parms",value="手机号码或者姓名",dataType="String", paramType = "query"),
			@ApiImplicitParam(name="pageNo",value="分页参数",dataType="int", paramType = "query")
	})
	public RespResult queryCardList(String token,String cardState,String parms,Integer pageNo) {
		List<Map<String,Object>> list = sysCardService.queryCardList( token, cardState, parms, pageNo);
		return RespResult.ok().put("list",list);
	}

	/**
	 * 信用卡查询奖励
	 * @param token 登录人token
	 * @param monthTime 审核状态
	 * @return
	 */
	@GetMapping("user/queryCardRewardMap")
	@ApiOperation("信用卡查询奖励")
	@ApiImplicitParams({
			@ApiImplicitParam(name="monthTime",value="月时间 yyyy-mm",dataType="String", paramType = "query" ,required = true)
	})
	public RespResult queryCardRewardMap(String token,String monthTime) {
		Map<String,Object> map = sysCardService.queryCardRewardMap(token,monthTime);
		return RespResult.ok(map);
	}

	/**
	 * 其它奖励明细奖励
	 * @param token
	 * @return
	 */
	@GetMapping("user/queryOtherAmountList")
	@ApiOperation("其它奖励明细奖励")
	public RespResult queryOtherAmountList(String token) {
		List<FlowAccountView> list = flowAccountService.queryOtherAmountList(token);
		return RespResult.ok().put("list",list);
	}
}
